/*
 * @Descripttion:调用后端购物车接口的函数
 * @Author: congz
 * @Date: 2020-06-14 15:50:08
 * @LastEditors: congz
 * @LastEditTime: 2020-08-05 15:33:58
 */
import request from '@/api/utils/request'
import axios from 'axios'

// 创建购物车
// const postCart = form => axios.post('/api/v1/carts', form).then(res => res.data)
export function addCart(form) {
  let target = '/addCart/'
  return request.post(target, form)
}

// 读取购物车
// const showCarts = user_id =>
//   axios.get(`/api/v1/carts/${user_id}`).then(res => res.data)
export function showCarts(user_id){
  let target = "/showCart?user_id="
  target += user_id
  return request.get(target)
}


// 更新购物车
export function updateCart(form){
  let target = '/updateCart/'
  return request.post(target, form)
}
// const updateCart = form =>
//   axios.put('/api/v1/carts', form).then(res => res.data)

// 删除购物车
export function deleteCart(form){
  let target = '/deleteCart/'
  return request.post(target, form)
}
// const deleteCart = form =>
//   axios.delete('/api/v1/carts', { data: form }).then(res => res.data)

